from scipy.stats import multivariate_normal
import matplotlib.pyplot as plt
import numpy as np

mean = [2, 5]
cov = [[1, 0.8], [0.8, 1]]
samples = multivariate_normal.rvs(mean=mean, cov=cov, size=500)

# 绘制散点图与等高线
x, y = samples[:, 0], samples[:, 1]
plt.scatter(x, y, alpha=0.5)
X, Y = np.mgrid[0:4:0.1, 3:7:0.1]
Z = multivariate_normal.pdf(np.dstack((X, Y)), mean, cov)
plt.contour(X, Y, Z, colors='red')
plt.show()